package com.xnx.bincker.leader.dao;

import com.xnx.bincker.leader.core.repository.BasicRepository;
import com.xnx.bincker.leader.domain.Menu;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.Collection;
import java.util.List;

public interface MenuRepository extends BasicRepository<Menu, String> {
    /**
     * 查询某角色下所有的菜单
     * @param roleCodeList 角色Code列表
     */
    @Query("select m from Menu m join m.authority.roles roles where m.display = true and roles.code in (:roleCodeList) order by m.order")
    List<Menu> queryRoleMenuList(@Param("roleCodeList")Collection<String> roleCodeList);
}
